﻿using System;
using Mono.Collections.Generic;

namespace Mono.Cecil.Cil
{
	// Token: 0x0200011D RID: 285
	public sealed class ILProcessor
	{
		// Token: 0x170002D6 RID: 726
		// (get) Token: 0x06000ADB RID: 2779 RVA: 0x00030FD4 File Offset: 0x0002F1D4
		public MethodBody Body
		{
			get
			{
				return this.body;
			}
		}

		// Token: 0x06000ADC RID: 2780 RVA: 0x00005DA8 File Offset: 0x00003FA8
		internal ILProcessor(MethodBody body)
		{
			this.body = body;
			this.instructions = body.Instructions;
		}

		// Token: 0x06000ADD RID: 2781 RVA: 0x00030FEC File Offset: 0x0002F1EC
		public Instruction Create(OpCode opcode)
		{
			return Instruction.Create(opcode);
		}

		// Token: 0x06000ADE RID: 2782 RVA: 0x00031004 File Offset: 0x0002F204
		public Instruction Create(OpCode opcode, TypeReference type)
		{
			return Instruction.Create(opcode, type);
		}

		// Token: 0x06000ADF RID: 2783 RVA: 0x00031020 File Offset: 0x0002F220
		public Instruction Create(OpCode opcode, CallSite site)
		{
			return Instruction.Create(opcode, site);
		}

		// Token: 0x06000AE0 RID: 2784 RVA: 0x0003103C File Offset: 0x0002F23C
		public Instruction Create(OpCode opcode, MethodReference method)
		{
			return Instruction.Create(opcode, method);
		}

		// Token: 0x06000AE1 RID: 2785 RVA: 0x00031058 File Offset: 0x0002F258
		public Instruction Create(OpCode opcode, FieldReference field)
		{
			return Instruction.Create(opcode, field);
		}

		// Token: 0x06000AE2 RID: 2786 RVA: 0x00031074 File Offset: 0x0002F274
		public Instruction Create(OpCode opcode, string value)
		{
			return Instruction.Create(opcode, value);
		}

		// Token: 0x06000AE3 RID: 2787 RVA: 0x00031090 File Offset: 0x0002F290
		public Instruction Create(OpCode opcode, sbyte value)
		{
			return Instruction.Create(opcode, value);
		}

		// Token: 0x06000AE4 RID: 2788 RVA: 0x000310AC File Offset: 0x0002F2AC
		public Instruction Create(OpCode opcode, byte value)
		{
			bool flag = opcode.OperandType == OperandType.ShortInlineVar;
			Instruction result;
			if (flag)
			{
				result = Instruction.Create(opcode, this.body.Variables[(int)value]);
			}
			else
			{
				bool flag2 = opcode.OperandType == OperandType.ShortInlineArg;
				if (flag2)
				{
					result = Instruction.Create(opcode, this.body.GetParameter((int)value));
				}
				else
				{
					result = Instruction.Create(opcode, value);
				}
			}
			return result;
		}

		// Token: 0x06000AE5 RID: 2789 RVA: 0x00031114 File Offset: 0x0002F314
		public Instruction Create(OpCode opcode, int value)
		{
			bool flag = opcode.OperandType == OperandType.InlineVar;
			Instruction result;
			if (flag)
			{
				result = Instruction.Create(opcode, this.body.Variables[value]);
			}
			else
			{
				bool flag2 = opcode.OperandType == OperandType.InlineArg;
				if (flag2)
				{
					result = Instruction.Create(opcode, this.body.GetParameter(value));
				}
				else
				{
					result = Instruction.Create(opcode, value);
				}
			}
			return result;
		}

		// Token: 0x06000AE6 RID: 2790 RVA: 0x0003117C File Offset: 0x0002F37C
		public Instruction Create(OpCode opcode, long value)
		{
			return Instruction.Create(opcode, value);
		}

		// Token: 0x06000AE7 RID: 2791 RVA: 0x00031198 File Offset: 0x0002F398
		public Instruction Create(OpCode opcode, float value)
		{
			return Instruction.Create(opcode, value);
		}

		// Token: 0x06000AE8 RID: 2792 RVA: 0x000311B4 File Offset: 0x0002F3B4
		public Instruction Create(OpCode opcode, double value)
		{
			return Instruction.Create(opcode, value);
		}

		// Token: 0x06000AE9 RID: 2793 RVA: 0x000311D0 File Offset: 0x0002F3D0
		public Instruction Create(OpCode opcode, Instruction target)
		{
			return Instruction.Create(opcode, target);
		}

		// Token: 0x06000AEA RID: 2794 RVA: 0x000311EC File Offset: 0x0002F3EC
		public Instruction Create(OpCode opcode, Instruction[] targets)
		{
			return Instruction.Create(opcode, targets);
		}

		// Token: 0x06000AEB RID: 2795 RVA: 0x00031208 File Offset: 0x0002F408
		public Instruction Create(OpCode opcode, VariableDefinition variable)
		{
			return Instruction.Create(opcode, variable);
		}

		// Token: 0x06000AEC RID: 2796 RVA: 0x00031224 File Offset: 0x0002F424
		public Instruction Create(OpCode opcode, ParameterDefinition parameter)
		{
			return Instruction.Create(opcode, parameter);
		}

		// Token: 0x06000AED RID: 2797 RVA: 0x00005DC5 File Offset: 0x00003FC5
		public void Emit(OpCode opcode)
		{
			this.Append(this.Create(opcode));
		}

		// Token: 0x06000AEE RID: 2798 RVA: 0x00005DD6 File Offset: 0x00003FD6
		public void Emit(OpCode opcode, TypeReference type)
		{
			this.Append(this.Create(opcode, type));
		}

		// Token: 0x06000AEF RID: 2799 RVA: 0x00005DE8 File Offset: 0x00003FE8
		public void Emit(OpCode opcode, MethodReference method)
		{
			this.Append(this.Create(opcode, method));
		}

		// Token: 0x06000AF0 RID: 2800 RVA: 0x00005DFA File Offset: 0x00003FFA
		public void Emit(OpCode opcode, CallSite site)
		{
			this.Append(this.Create(opcode, site));
		}

		// Token: 0x06000AF1 RID: 2801 RVA: 0x00005E0C File Offset: 0x0000400C
		public void Emit(OpCode opcode, FieldReference field)
		{
			this.Append(this.Create(opcode, field));
		}

		// Token: 0x06000AF2 RID: 2802 RVA: 0x00005E1E File Offset: 0x0000401E
		public void Emit(OpCode opcode, string value)
		{
			this.Append(this.Create(opcode, value));
		}

		// Token: 0x06000AF3 RID: 2803 RVA: 0x00005E30 File Offset: 0x00004030
		public void Emit(OpCode opcode, byte value)
		{
			this.Append(this.Create(opcode, value));
		}

		// Token: 0x06000AF4 RID: 2804 RVA: 0x00005E42 File Offset: 0x00004042
		public void Emit(OpCode opcode, sbyte value)
		{
			this.Append(this.Create(opcode, value));
		}

		// Token: 0x06000AF5 RID: 2805 RVA: 0x00005E54 File Offset: 0x00004054
		public void Emit(OpCode opcode, int value)
		{
			this.Append(this.Create(opcode, value));
		}

		// Token: 0x06000AF6 RID: 2806 RVA: 0x00005E66 File Offset: 0x00004066
		public void Emit(OpCode opcode, long value)
		{
			this.Append(this.Create(opcode, value));
		}

		// Token: 0x06000AF7 RID: 2807 RVA: 0x00005E78 File Offset: 0x00004078
		public void Emit(OpCode opcode, float value)
		{
			this.Append(this.Create(opcode, value));
		}

		// Token: 0x06000AF8 RID: 2808 RVA: 0x00005E8A File Offset: 0x0000408A
		public void Emit(OpCode opcode, double value)
		{
			this.Append(this.Create(opcode, value));
		}

		// Token: 0x06000AF9 RID: 2809 RVA: 0x00005E9C File Offset: 0x0000409C
		public void Emit(OpCode opcode, Instruction target)
		{
			this.Append(this.Create(opcode, target));
		}

		// Token: 0x06000AFA RID: 2810 RVA: 0x00005EAE File Offset: 0x000040AE
		public void Emit(OpCode opcode, Instruction[] targets)
		{
			this.Append(this.Create(opcode, targets));
		}

		// Token: 0x06000AFB RID: 2811 RVA: 0x00005EC0 File Offset: 0x000040C0
		public void Emit(OpCode opcode, VariableDefinition variable)
		{
			this.Append(this.Create(opcode, variable));
		}

		// Token: 0x06000AFC RID: 2812 RVA: 0x00005ED2 File Offset: 0x000040D2
		public void Emit(OpCode opcode, ParameterDefinition parameter)
		{
			this.Append(this.Create(opcode, parameter));
		}

		// Token: 0x06000AFD RID: 2813 RVA: 0x00031240 File Offset: 0x0002F440
		public void InsertBefore(Instruction target, Instruction instruction)
		{
			bool flag = target == null;
			if (flag)
			{
				throw new ArgumentNullException("target");
			}
			bool flag2 = instruction == null;
			if (flag2)
			{
				throw new ArgumentNullException("instruction");
			}
			int num = this.instructions.IndexOf(target);
			bool flag3 = num == -1;
			if (flag3)
			{
				throw new ArgumentOutOfRangeException("target");
			}
			this.instructions.Insert(num, instruction);
		}

		// Token: 0x06000AFE RID: 2814 RVA: 0x000312A4 File Offset: 0x0002F4A4
		public void InsertAfter(Instruction target, Instruction instruction)
		{
			bool flag = target == null;
			if (flag)
			{
				throw new ArgumentNullException("target");
			}
			bool flag2 = instruction == null;
			if (flag2)
			{
				throw new ArgumentNullException("instruction");
			}
			int num = this.instructions.IndexOf(target);
			bool flag3 = num == -1;
			if (flag3)
			{
				throw new ArgumentOutOfRangeException("target");
			}
			this.instructions.Insert(num + 1, instruction);
		}

		// Token: 0x06000AFF RID: 2815 RVA: 0x00031308 File Offset: 0x0002F508
		public void InsertAfter(int index, Instruction instruction)
		{
			bool flag = index < 0 || index >= this.instructions.Count;
			if (flag)
			{
				throw new ArgumentOutOfRangeException("index");
			}
			bool flag2 = instruction == null;
			if (flag2)
			{
				throw new ArgumentNullException("instruction");
			}
			this.instructions.Insert(index + 1, instruction);
		}

		// Token: 0x06000B00 RID: 2816 RVA: 0x00031360 File Offset: 0x0002F560
		public void Append(Instruction instruction)
		{
			bool flag = instruction == null;
			if (flag)
			{
				throw new ArgumentNullException("instruction");
			}
			this.instructions.Add(instruction);
		}

		// Token: 0x06000B01 RID: 2817 RVA: 0x00031390 File Offset: 0x0002F590
		public void Replace(Instruction target, Instruction instruction)
		{
			bool flag = target == null;
			if (flag)
			{
				throw new ArgumentNullException("target");
			}
			bool flag2 = instruction == null;
			if (flag2)
			{
				throw new ArgumentNullException("instruction");
			}
			this.InsertAfter(target, instruction);
			this.Remove(target);
		}

		// Token: 0x06000B02 RID: 2818 RVA: 0x000313D8 File Offset: 0x0002F5D8
		public void Replace(int index, Instruction instruction)
		{
			bool flag = instruction == null;
			if (flag)
			{
				throw new ArgumentNullException("instruction");
			}
			this.InsertAfter(index, instruction);
			this.RemoveAt(index);
		}

		// Token: 0x06000B03 RID: 2819 RVA: 0x0003140C File Offset: 0x0002F60C
		public void Remove(Instruction instruction)
		{
			bool flag = instruction == null;
			if (flag)
			{
				throw new ArgumentNullException("instruction");
			}
			bool flag2 = !this.instructions.Remove(instruction);
			if (flag2)
			{
				throw new ArgumentOutOfRangeException("instruction");
			}
		}

		// Token: 0x06000B04 RID: 2820 RVA: 0x0003144C File Offset: 0x0002F64C
		public void RemoveAt(int index)
		{
			bool flag = index < 0 || index >= this.instructions.Count;
			if (flag)
			{
				throw new ArgumentOutOfRangeException("index");
			}
			this.instructions.RemoveAt(index);
		}

		// Token: 0x06000B05 RID: 2821 RVA: 0x00005EE4 File Offset: 0x000040E4
		public void Clear()
		{
			this.instructions.Clear();
		}

		// Token: 0x040005CC RID: 1484
		private readonly MethodBody body;

		// Token: 0x040005CD RID: 1485
		private readonly Collection<Instruction> instructions;
	}
}
